package com.zzt.spider.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzt.spider.model.entity.SpiderSource;
import com.zzt.spider.model.mapper.SpiderSourceMapper;
import com.zzt.spider.service.SpiderSourceService;
import org.springframework.stereotype.Service;

@Service
public class SpiderSourceServiceImpl extends ServiceImpl<SpiderSourceMapper, SpiderSource> implements SpiderSourceService {
    public void saveSource(SpiderSource source) {
        if (source != null) {
            boolean saveFlag = exists((new LambdaQueryWrapper<SpiderSource>()).eq(SpiderSource::getUrl, source.getUrl()));
            if (!saveFlag) {
                this.save(source);
            }

        }
    }
}
